package com.benshou.bsoa.dao.params;

import com.baomidou.mybatisplus.core.conditions.AbstractLambdaWrapper;
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import com.baomidou.mybatisplus.extension.conditions.AbstractChainWrapper;
import com.benshou.bsoa.common.dao.params.QueryParams;
import com.benshou.bsoa.model.Test;
import lombok.Builder;
import lombok.NonNull;

/**
 * @author <a href="mailto:liuzhenbang@benshou.com">Liu Zhenbang</a>
 */
@Builder
public record TestParams(
        String testNo
) implements QueryParams<Test> {

    @Override
    public <Wrapper extends AbstractChainWrapper<Test, SFunction<Test, ?>, Wrapper, Lambda>, Lambda extends AbstractLambdaWrapper<Test, Lambda>> Wrapper applyParams(@NonNull Wrapper wrapper) {
        return wrapper
                .eq(this.testNo != null, Test::getTestNo, this.testNo);
    }
}
